CREATE TABLE [dbo].[tb_Tareas]
(
[idTarea] [int] NOT NULL IDENTITY(1, 1),
[Proceso] [int] NOT NULL,
[Nombre] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Duracion] [int] NOT NULL,
[Tipo] [int] NOT NULL,
[SenalEspera] [int] NULL,
[SubProceso] [int] NULL,
[Anterior] [int] NULL,
[Anterior2] [int] NULL,
[Posterior] [int] NULL,
[Posterior2] [int] NULL,
[Devolucion] [int] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[tb_Tareas] ADD CONSTRAINT [PK_tb_Tareas] PRIMARY KEY NONCLUSTERED  ([idTarea]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[tb_Tareas] ADD CONSTRAINT [FK_tb_Tareas_tb_Tareas] FOREIGN KEY ([Anterior]) REFERENCES [dbo].[tb_Tareas] ([idTarea])
GO
ALTER TABLE [dbo].[tb_Tareas] ADD CONSTRAINT [FK_tb_Tareas_tb_Tareas1] FOREIGN KEY ([Anterior2]) REFERENCES [dbo].[tb_Tareas] ([idTarea])
GO
ALTER TABLE [dbo].[tb_Tareas] ADD CONSTRAINT [FK_tb_Tareas_tb_Tareas4] FOREIGN KEY ([Devolucion]) REFERENCES [dbo].[tb_Tareas] ([idTarea])
GO
ALTER TABLE [dbo].[tb_Tareas] ADD CONSTRAINT [FK_tb_Tareas_tb_Tareas2] FOREIGN KEY ([Posterior]) REFERENCES [dbo].[tb_Tareas] ([idTarea])
GO
ALTER TABLE [dbo].[tb_Tareas] ADD CONSTRAINT [FK_tb_Tareas_tb_Tareas3] FOREIGN KEY ([Posterior2]) REFERENCES [dbo].[tb_Tareas] ([idTarea])
GO
ALTER TABLE [dbo].[tb_Tareas] ADD CONSTRAINT [FK_tb_Tareas_tb_Procesos] FOREIGN KEY ([Proceso]) REFERENCES [dbo].[tb_Procesos] ([idProceso])
GO
ALTER TABLE [dbo].[tb_Tareas] ADD CONSTRAINT [FK_tb_Tareas_tb_SenalesDeEspera] FOREIGN KEY ([SenalEspera]) REFERENCES [dbo].[tb_SenalesDeEspera] ([idSenalEspera])
GO
ALTER TABLE [dbo].[tb_Tareas] ADD CONSTRAINT [FK_tb_Tareas_tb_Procesos1] FOREIGN KEY ([SubProceso]) REFERENCES [dbo].[tb_Procesos] ([idProceso])
GO
ALTER TABLE [dbo].[tb_Tareas] ADD CONSTRAINT [FK_tb_Tareas_tb_TiposDeTareas] FOREIGN KEY ([Tipo]) REFERENCES [dbo].[tb_TiposDeTareas] ([idTipoDeTarea])
GO
